<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Lists all of the databases available</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="mongoclient.killcursor.html">« MongoClient::killCursor</a></li>
      <li style="float: right;"><a href="mongoclient.selectcollection.html">MongoClient::selectCollection »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.mongoclient.html">MongoClient</a></li>
    <li>Lists all of the databases available</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="mongoclient.listdbs" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">MongoClient::listDBs</h1>
  <p class="verinfo">(PECL mongo &gt;=1.3.0)</p><p class="refpurpose"><span class="refname">MongoClient::listDBs</span> &mdash; <span class="dc-title">Lists all of the databases available</span></p>

 </div>

 <div id="mongoclient.listdbs-soft-deprecation-notice" class="soft-deprecation-notice">
  <p class="para">This extension that defines this method
is deprecated. Instead, the <a href="" class="link">MongoDB</a> extension should be used.
There is no equivalent for this method in the new extension, but there is an
alternative in the <a href="" class="link">PHP library</a>:</p>
  <ul class="simplelist">
   <li class="member"><a href="https://docs.mongodb.com/php-library/master/reference/method/MongoDBClient-listDatabases/" class="link external">&raquo;&nbsp;MongoDB\Client::listDatabases()</a></li>
  </ul>
 </div>

 <div class="refsect1 description" id="refsect1-mongoclient.listdbs-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>MongoClient::listDBs</strong></span>(): <span class="type">array</span></div>

 </div>


 <div class="refsect1 parameters" id="refsect1-mongoclient.listdbs-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">This function has no parameters.</p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-mongoclient.listdbs-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns an associative array containing three fields.  The first field is
   <code class="literal">databases</code>, which in turn contains an array.  Each element
   of the array is an associative array corresponding to a database, giving th
   database&#039;s name, size, and if it&#039;s empty.  The other two fields are
   <code class="literal">totalSize</code> (in bytes) and <code class="literal">ok</code>, which is 1
   if this method ran successfully.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-mongoclient.listdbs-examples">
  <h3 class="title">Examples</h3>
  <div class="example" id="example-60">
   <p><strong>Example #1 <span class="methodname"><strong>MongoClient::listDBs()</strong></span> example</strong></p>
   <div class="example-contents"><p>
    Example demonstrating how to use listDBs and the returned data structure.
   </p></div>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$mongo&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">MongoClient</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$dbs&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$mongo</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">listDBs</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$dbs</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>The above example will output
something similar to:</p></div>
   <div class="example-contents screen">
<div class="cdata"><pre>
Array
(
    [databases] =&gt; Array
        (
            [0] =&gt; Array
                (
                    [name] =&gt; doctrine
                    [sizeOnDisk] =&gt; 218103808
                    [empty] =&gt;
                )
        )

    [totalSize] =&gt; 218103808
    [ok] =&gt; 1
)

</pre></div>
   </div>
  </div>
 </div>

</div></div></div></body></html>